<!--

    Copyright © 2016-2022 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section class="tb-widget-settings" [formGroup]="analogueCompassWidgetSettingsForm" fxLayout="column">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.gauge.ticks-settings</legend>
    <mat-form-field fxFlex class="mat-block" floatLabel="always">
      <mat-label translate>widgets.gauge.major-ticks-names</mat-label>
      <mat-chip-list class="tb-drop-list"
                     #majorTicksNamesChipList
                     cdkDropList
                     cdkDropListOrientation="horizontal"
                     (cdkDropListDropped)="majorTickNameDrop($event)"
                     formControlName="majorTicks">
        <mat-chip class="tb-draggable" cdkDrag *ngFor="let tickName of majorTicksNamesList()"
                  [removable]="true" (removed)="removeMajorTickName(tickName)">
          {{tickName}}
          <mat-icon matChipRemove>cancel</mat-icon>
        </mat-chip>
        <input [matChipInputFor]="majorTicksNamesChipList"
               [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
               matChipInputAddOnBlur
               (matChipInputTokenEnd)="addMajorTickName($event)">
      </mat-chip-list>
    </mat-form-field>
    <tb-color-input fxFlex
                    formControlName="colorMajorTicks"
                    icon="format_color_fill"
                    label="{{ 'widgets.gauge.major-ticks-color' | translate }}" openOnInput colorClearButton>
    </tb-color-input>
    <section class="row-fill" fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
      <mat-form-field fxFlex class="mat-block">
        <mat-label translate>widgets.gauge.minor-ticks-count</mat-label>
        <input matInput type="number" min="0" formControlName="minorTicks">
      </mat-form-field>
      <tb-color-input fxFlex
                      formControlName="colorMinorTicks"
                      icon="format_color_fill"
                      label="{{ 'widgets.gauge.minor-ticks-color' | translate }}" openOnInput colorClearButton>
      </tb-color-input>
    </section>
    <mat-slide-toggle formControlName="showStrokeTicks" class="slide-block">
      {{ 'widgets.gauge.show-stroke-ticks' | translate }}
    </mat-slide-toggle>
    <fieldset class="fields-group">
      <legend class="group-title" translate>widgets.gauge.major-ticks-font</legend>
      <tb-widget-font formControlName="majorTickFont"></tb-widget-font>
    </fieldset>
  </fieldset>
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.gauge.plate-settings</legend>
    <tb-color-input fxFlex
                    formControlName="colorPlate"
                    icon="format_color_fill"
                    label="{{ 'widgets.gauge.plate-color' | translate }}" openOnInput colorClearButton>
    </tb-color-input>
    <mat-slide-toggle formControlName="showBorder" class="slide-block">
      {{ 'widgets.gauge.show-plate-border' | translate }}
    </mat-slide-toggle>
    <section class="row-fill" fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
      <tb-color-input fxFlex
                      formControlName="colorBorder"
                      icon="format_color_fill"
                      label="{{ 'widgets.gauge.border-color' | translate }}" openOnInput colorClearButton>
      </tb-color-input>
      <mat-form-field fxFlex class="mat-block">
        <mat-label translate>widgets.gauge.border-width</mat-label>
        <input matInput type="number" min="0" formControlName="borderOuterWidth">
      </mat-form-field>
    </section>
  </fieldset>
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.gauge.needle-settings</legend>
    <mat-form-field fxFlex class="mat-block">
      <mat-label translate>widgets.gauge.needle-circle-size</mat-label>
      <input matInput type="number" min="0" formControlName="needleCircleSize">
    </mat-form-field>
    <section fxLayout="row wrap" fxLayoutGap="8px" fxLayoutAlign="start center">
      <tb-color-input fxFlex
                      formControlName="colorNeedle"
                      icon="format_color_fill"
                      label="{{ 'widgets.gauge.needle-color' | translate }}" openOnInput colorClearButton>
      </tb-color-input>
      <tb-color-input fxFlex
                      formControlName="colorNeedleCircle"
                      icon="format_color_fill"
                      label="{{ 'widgets.gauge.needle-circle-color' | translate }}" openOnInput colorClearButton>
      </tb-color-input>
    </section>
  </fieldset>
  <fieldset class="fields-group fields-group-slider">
    <legend class="group-title" translate>widgets.gauge.animation-settings</legend>
    <mat-expansion-panel class="tb-settings" [expanded]="analogueCompassWidgetSettingsForm.get('animation').value">
      <mat-expansion-panel-header fxLayout="row wrap">
        <mat-panel-title>
          <mat-slide-toggle formControlName="animation" (click)="$event.stopPropagation()"
                            fxLayoutAlign="center">
            {{ 'widgets.gauge.enable-animation' | translate }}
          </mat-slide-toggle>
        </mat-panel-title>
        <mat-panel-description fxLayoutAlign="end center" fxHide.xs translate>
          widget-config.advanced-settings
        </mat-panel-description>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <section fxLayout="column">
          <mat-form-field fxFlex class="mat-block">
            <mat-label translate>widgets.gauge.animation-duration</mat-label>
            <input matInput type="number" min="0" formControlName="animationDuration">
          </mat-form-field>
          <mat-form-field fxFlex class="mat-block">
            <mat-label translate>widgets.gauge.animation-rule</mat-label>
            <mat-select formControlName="animationRule">
              <mat-option [value]="'linear'">
                {{ 'widgets.gauge.animation-linear' | translate }}
              </mat-option>
              <mat-option [value]="'quad'">
                {{ 'widgets.gauge.animation-quad' | translate }}
              </mat-option>
              <mat-option [value]="'quint'">
                {{ 'widgets.gauge.animation-quint' | translate }}
              </mat-option>
              <mat-option [value]="'cycle'">
                {{ 'widgets.gauge.animation-cycle' | translate }}
              </mat-option>
              <mat-option [value]="'bounce'">
                {{ 'widgets.gauge.animation-bounce' | translate }}
              </mat-option>
              <mat-option [value]="'elastic'">
                {{ 'widgets.gauge.animation-elastic' | translate }}
              </mat-option>
              <mat-option [value]="'dequad'">
                {{ 'widgets.gauge.animation-dequad' | translate }}
              </mat-option>
              <mat-option [value]="'dequint'">
                {{ 'widgets.gauge.animation-dequint' | translate }}
              </mat-option>
              <mat-option [value]="'decycle'">
                {{ 'widgets.gauge.animation-decycle' | translate }}
              </mat-option>
              <mat-option [value]="'debounce'">
                {{ 'widgets.gauge.animation-debounce' | translate }}
              </mat-option>
              <mat-option [value]="'delastic'">
                {{ 'widgets.gauge.animation-delastic' | translate }}
              </mat-option>
            </mat-select>
          </mat-form-field>
          <mat-form-field fxFlex class="mat-block">
            <mat-label translate>widgets.gauge.animation-target</mat-label>
            <mat-select formControlName="animationTarget">
              <mat-option [value]="'needle'">
                {{ 'widgets.gauge.animation-target-needle' | translate }}
              </mat-option>
              <mat-option [value]="'plate'">
                {{ 'widgets.gauge.animation-target-plate' | translate }}
              </mat-option>
            </mat-select>
          </mat-form-field>
        </section>
      </ng-template>
    </mat-expansion-panel>
  </fieldset>
</section>
